#include "Core/Array/Stack.h"
#include "StackTest.h"


const char * StackTest::GetName() const
{
	return "Stack Test";
}

error StackTest::Create()
{
	if(Failed(UnitTest::Create()))
		return errFailed;

	return errOK;
}

error StackTest::Destroy()
{
	if(Failed(UnitTest::Destroy()))
		return errFailed;

	return errOK;
}

error StackTest::Execute()
{
	Stack<int> stack;
	stack.Push(4);
	stack.Push(8);
	stack.Push(6);
	stack.Push(0);
	stack.Push(-8);

	if(stack.Size()!=5)
		return errFailed;

	int stackTop = stack.Pop();

	if(stackTop!=-8)
		return errFailed;

	if(stack.Size()!=4)
		return errFailed;

	stackTop = stack.Pop();

	if(stackTop!=0)
		return errFailed;

	if(stack.Size()!=3)
		return errFailed;

	stackTop = stack.Pop();

	if(stackTop!=6)
		return errFailed;

	if(stack.Size()!=2)
		return errFailed;

	stackTop = stack.Pop();

	if(stackTop!=8)
		return errFailed;

	if(stack.Size()!=1)
		return errFailed;

	stackTop = stack.Pop();

	if(stackTop!=4)
		return errFailed;

	if(stack.Size()!=0)
		return errFailed;


	return errOK;
}
